package com.cat.dataStructure;

import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeMap;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/my-calendar-iii/description/
 * @create 2025/8/24 14:44
 * @since JDK17
 */

public class MyCalendarThree {
    static TreeMap<Integer, Integer> map = new TreeMap<>();
    static int ans;
    public MyCalendarThree() {
        map.clear();
        ans = 0;
    }

    public int book(int startTime, int endTime) {
        map.merge(startTime, 1, Integer::sum);
        // map.merge(endTime, -1, Integer::sum);
        int sum = 0;
        for (Integer value : map.values()) {
            sum += value;
            ans = Math.max(ans, sum);
        }
        return ans;
    }
}